<?php
   
  $layoutId = $cgi->getValue ( "propertyref" );

  $rows = $sql->execute ( "
    SELECT
      p.id                AS property_id,
      p.propertyref       AS propertyref,
      p.propertyaddress   AS propertyaddress,
      p.propertyprice     AS propertyprice,
      p.propertyphoto1  AS propertyphoto1,
      p.shortdescription  AS shortdescription,
      p.longdescription  AS longdescription,
      p.propertybathrooms  AS propertybathrooms,
      p.propertyheating  AS propertyheating,
      p.propertyyearbuilt  AS propertyyearbuilt,
      p.propertylivingarea  AS propertylivingarea,
      p.propertyplotsize  AS propertyplotsize,
      p.propertyswimmingpool  AS propertyswimmingpool,
      p.propertygarage  AS propertygarage,
      p.propertyfurnished  AS propertyfurnished,
      pt.propertytype     AS propertytype,
      pl.propertylocation AS propertylocation,
      ps.propertystatus   AS propertystatus
    FROM
      " . $property_table . " p
      INNER JOIN
      " . $propertytypes_table . " pt ON (p.propertytype=pt.id)
      INNER JOIN
      " . $propertylocations_table . " pl ON (p.propertylocation=pl.id)
      INNER JOIN
      " . $propertystatus_table . " ps ON (p.propertystatus=ps.id)
    WHERE propertyref=" .
    $sql->quote ( $layoutId ) . "  LIMIT 1",
    SQL_RETURN_ASSOC );


  $row = $rows [ 0 ];

  $Price = number_format ( $row [ 'propertyprice' ], PRICE_FORMAT ); 
   


?><br><br>
<TABLE WIDTH="100%"  ALIGN="CENTER"> 
<TR VALIGN="MIDDLE"> 
<TD><P class="factsheet_title">&nbsp;&nbsp;&nbsp;<?php echo LV_PROPERTY_REF; ?> <strong><?php echo $row [ "propertyref" ]; ?></strong> - <?php echo $row [ "propertyaddress" ]; ?> <?php echo $_GET [ "pl" ]; ?></P></TD>
<TD ALIGN="right" VALIGN="TOP">&nbsp;</TD>

</TR> 
</TABLE> 
<TABLE WIDTH="100%" CELLPADDING="3" CELLSPACING="10" ALIGN="CENTER"> 
<TR VALIGN="TOP"> 
<TD VALIGN="TOP"> 

<?php   if ( ! $row [ 'propertyphoto1' ] )
  {
    ?><img src="<?php echo $ImageURL; ?>nopropertyimage.jpg" border="0" align="left" hspace="10"><?php
  }
  else
  {
    ?><img src="<?php echo $ImageURL; ?><?php
    echo $row [ "propertyphoto1" ]; ?>"  border="0" align="left" hspace="10"> <?php } ?>

 </TD> 
<TD VALIGN="TOP"><p><?php 
 echo $row [ "shortdescription" ]; ?></p>
<table width="95%"  border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="50%" valign="top"><ul><?php
  if ( $row [ 'propertybathrooms' ] ) {echo "<li><p>$row[propertybathrooms] Bathrooms</p></li>";}
  if ( $row [ 'propertyheating' ] ) {echo "<li><p>$row[propertyheating]</p></li>";}
  if ( $row [ 'propertyyearbuilt' ] ) {echo "<li><p>Built in $row[propertyyearbuilt]</p></li>";}
  if ( $row [ 'propertylivingarea' ] ) {echo "<li><p>$row[propertylivingarea] Living Area</p></li>";}
 ?></ul></td>
<td width="50%" valign="top"><ul><?php 
  if ( $row [ 'propertyplotsize' ] ) {echo "<li><p>$row[propertyplotsize] Plot Size</p></li>";}
  if ( $row [ "propertyswimmingpool" ] == "1" ) { echo "<li><p>Swimming Pool</p></li>"; }
  if ( $row [ 'propertygarage' ] == "1"  ) {echo "<li><p>Garage</p></li>";}
  if ( $row [ 'propertyfurnished' ] == "1"  ) {echo "<li><p>Furnished</p></li>";}
?></ul></td>
</tr>
</table></TD>
</TR>
<TR VALIGN="TOP">
<TD colspan="2" VALIGN="TOP">
<P align="left"><?php echo nl2br($row [ "longdescription" ]); ?></P>
<h2 align="center"><?php echo LR_PROPERTY_PRICE; ?> <?php echo CURRENCY; ?><?php echo "$Price"; ?></h2></TD>
</TR>
</TABLE>
